#!/usr/bin/env python
# -*- coding:utf-8 -*-

import sys
import getopt

if __name__ == '__main__':
    """
    argv learn
    """
    argv = sys.argv
    print("argv = {}".format(argv))

    # 函数处理命令行参数
    opts, args = getopt.getopt(argv[1:], "h:a:", ["p="])
    print("opts = {}, args = {}".format(opts, args)) # args是多余的参数，不能再中间写入
    print("h = {} ".format(opts[0][0]))

    # 日常使用的方式
    for k, v in opts:
        if k in ("-h"):
            print("-h value = {}".format(v))
        if k in ("--p"):
            print("--p value = {}".format(v))
